local liyue = fk.CreateSkill{
    name = "lingling__liyue"
}
Fk:loadTranslationTable{
    ["lingling__liyue"] = "礼乐",
    [":lingling__liyue"] = "出牌阶段，你可以将两张花色相同的“治”当任意普通锦囊牌使用，然后摸一张牌。每回合每种牌名限一次。当你造成伤害后，此技能本回合无效。",
}

liyue:addEffect("viewas",{
    pattern = "^nullification|.|.|.|.|trick",
    prompt = "#lingling__liyue",
    interaction = function(self, player)
        local all_names = Fk:getAllCardNames("t")
        local names = player:getViewAsCardNames(liyue.name, all_names, nil,player:getTableMark("lingling__liyue-turn"))
        if #names == 0 then return end
        return UI.CardNameBox { choices = names, all_choices = all_names }
    end,
    expand_pile = "lingling__xingzhi_power",
    card_filter = function(self, player, to_select, selected)
        if #selected < 2 and player:getPileNameOfId(to_select) == "lingling__xingzhi_power" then
            if #selected == 0 then
                return table.find(player:getPile("lingling__xingzhi_power"),function (cardID)
                    return cardID ~= to_select and Fk:getCardById(to_select).suit == Fk:getCardById(cardID).suit
                end)
            else
                return Fk:getCardById(to_select).suit == Fk:getCardById(selected[1]).suit
            end
        end
    end,
    view_as = function (self, player, cards)
        if #cards ~= 2 or not self.interaction.data then return end
        local card = Fk:cloneCard(self.interaction.data)
        card:addSubcards(cards)
        card.skillName = liyue.name
        return card
    end,
    before_use = function (self, player, use)
        player.room:addTableMark(player, "lingling__liyue-turn", use.card.trueName)
    end,
    after_use = function (self, player, use)
        if #use.card.subcards > 2 and not player.dead then
        player:drawCards(1, liyue.name)
        end
    end,
    enabled_at_response = Util.FalseFunc,
})

liyue:addEffect(fk.Damage,{
    can_trigger = function (self, event, target, player, data)
        return target == player and player:hasSkill(liyue.name)
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        player.room:invalidateSkill(player, liyue.name, "-turn", liyue.name)
    end,
})

return liyue